export function getScrollTop() {

    var scrollTop = 0,
        bodyScrollTop = 0,
        documentScrollTop = 0;

    if (document.body) {
        bodyScrollTop = document.body.scrollTop;
    }

    if (document.documentElement) {
        documentScrollTop = document.documentElement.scrollTop;
    }

    scrollTop = (bodyScrollTop - documentScrollTop > 0) ? bodyScrollTop : documentScrollTop;


    return scrollTop;
}

export function getOffset(el) {

    var __element = el;

    if (!__element) {

        return {
	        top: 0,
	        left: 0,
	        width: 0,
	        height: 0
        };
    }

    var __offset = {
        top: __element.offsetTop,
        left: __element.offsetLeft,
        width:__element.offsetWidth,
        height: __element.offsetHeight
    };

    while (__element != document.body) {

        __element = __element.offsetParent;

        __offset.top += __element.offsetTop;
        __offset.left += __element.offsetLeft;
    }

    return __offset;
}

function getScrollHeight() {

    var scrollHeight = 0,
        bodyScrollHeight = 0,
        documentScrollHeight = 0;

    if (document.body) {
        bodyScrollHeight = document.body.scrollHeight;
    }

    if (document.documentElement) {
        documentScrollHeight = document.documentElement.scrollHeight;
    }

    scrollHeight = (bodyScrollHeight - documentScrollHeight > 0) ? bodyScrollHeight : documentScrollHeight;

    return scrollHeight;
}

function getWindowHeight() {

    var windowHeight = 0;

    if(document.compatMode == "CSS1Compat"){
        windowHeight = document.documentElement.clientHeight;
    }else{
        windowHeight = document.body.clientHeight;
    }

    return windowHeight;
}

export function isScrollBottom() {

    if (getScrollTop() + getWindowHeight() == getScrollHeight()) {

        return true;
    }
    return false
}


export default {}